/*
 *  $Id: SecondBirth.cs 972 2009-12-15 16:53:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Water.Abilities {
    public class SecondBirth: AbilityCard<GraveyardData> {
        public SecondBirth(): base("001_w_a_second_birth") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Water;
            Target = new GraveyardTarget(GetTargetPhrase(), true, true, IsJellyfish);
            AddCondition(new CreaturesCondition(true, 1));
        }

        private static bool IsJellyfish(TargetRequest request, GraveyardItem item) {
            return item.CanResurrect && item.Card.Race.IsRace<Races.Jellyfish>();
        }

        private static readonly Languages.CardPhrase<SecondBirth> Action = new Languages.CardPhrase<SecondBirth>("action");

        protected override void DoAction(TargetArgs<GraveyardData> args) {
            int place = args.Player.GetRandomFreePlace();
            if (place < 0) return;
            args.Player.Game.Log.Add(Action.Phrase, args.Caster, args.Target.Item.Card);
            args.Target.Owner.ResurrectCreatureToPlayer(args.Player, args.Target.Item, place, false);
        }
    }
}
